package com.sais.manage.boot.cms.service.impl;


import com.sais.manage.boot.cms.dto.ContentDTO;
import com.sais.manage.boot.cms.entity.Content;
import com.sais.manage.boot.cms.mapper.ContentMapper;
import com.sais.manage.boot.cms.service.IContentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 博客-文章内容 service 实现类
 *
 * @author zwp
 * @date 2020/02/16
 **/
@Slf4j
@Service
public class ContentServiceImpl implements IContentService {

    @Resource
    private ContentMapper contentMapper;


    @Override
    public boolean createContent(Content content) {
        contentMapper.createContent(content);
        return true;
    }

    @Override
    public boolean updateContent(String articleId, String content) {
        contentMapper.updateContent(articleId, content);
        return true;
    }

    @Override
    @Transactional(rollbackFor = {Exception.class})
    public boolean deleteContentByArticleId(String articleId) {
        contentMapper.deleteContentByArticleId(articleId);
        return false;
    }

    @Override
    public ContentDTO selectContentByArticleId(String articleId) {
        ContentDTO contentDTO = contentMapper.selectContentByArticleId(articleId);
        return contentDTO;
    }
}
